# $Id$
# Maintainer: AndyRTR <andyrtr@archlinux.org>
# Contributor: Gerhard Brauer <gerbra@archlinux.de>
# Contributor: Richard Murri <admin@richardmurri.com>

pkgbase=x2goclient
pkgname=('x2goclient' 'x2goplugin' 'x2goplugin-provider')
pkgver=4.1.0.1
pkgrel=1
arch=('i686' 'x86_64')
license=('GPL2')
url="http://www.x2go.org"
makedepends=('qt4'
             #'qt5-x11extras' 'qt5-tools' 'qt5-svg' 'phonon-qt5'
             'libldap' 'libcups' 'nxproxy' 'libssh' 'libxpm' 
             'man2html' 'hicolor-icon-theme' 'xdg-utils' 'xorg-xauth')
source=(https://code.x2go.org/releases/source/${pkgname}/${pkgname}-${pkgver}.tar.gz{,.asc})
sha256sums=('0681b8a11b02652643cf1451a75d812c3ce9f3ee33c348b34178c130dcf77484'
            'SKIP')
validpgpkeys=('9BFBAEE86C0AA5FFBF2207829AF46B3025771B31'  # Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
              '1AD23D1B8F087A35AB74BDE9F4A7678C9C6B0B2B') #  "X2go Git Administrator <git-admin@x2go.org>"

prepare() {
  cd ${pkgname}-${pkgver}
  sed -i "s:-o root -g root ::" Makefile
}

build() {
  cd ${pkgname}-${pkgver}
  make PREFIX=/usr
  make PREFIX=/usr build_man
}

package_x2goclient() {
  
  pkgdesc="a graphical client (Qt4) for the X2Go system"
  depends=('qt4' 'libldap' 'libcups' 'nxproxy' 'libssh' 'libxpm' 'hicolor-icon-theme')
  # FS#48088
  optdepends=('xorg-xauth: may be required by X2goservers running a different linux distribution giving MIT-COOKIE errors')

  cd ${pkgbase}-${pkgver}
  make PREFIX=/usr DESTDIR="$pkgdir" install_client install_man
}

package_x2goplugin() {
  pkgdesc="provides X2Go Client as QtBrowser-based Mozilla plugin"
  depends=('qt4'  'libcups' 'nxproxy' 'libssh' 'libxpm')
  
  cd ${pkgbase}-${pkgver}
  make PREFIX=/usr DESTDIR="$pkgdir" install_plugin
}

package_x2goplugin-provider() {
  
  pkgdesc="an example configuration for providing the X2Go Plugin via an Apache webserver"
  depends=('apache')
  backup=(etc/x2go/plugin-provider/x2goplugin.html
          etc/x2go/x2goplugin-apache.conf
          etc/httpd/conf/x2goplugin-apache.conf)
  	
  cd ${pkgbase}-${pkgver}
  make PREFIX=/usr DESTDIR="$pkgdir" install_pluginprovider
  
  install -dm755 ${pkgdir}/etc/httpd/conf
  cd ${pkgdir}/etc/httpd/conf
  ln -svf /etc/x2go/x2goplugin-apache.conf ${pkgdir}/etc/httpd/conf/x2goplugin-apache.conf 
}
